package com.iflytek.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iflytek.entity.User;
import com.iflytek.service.UserService;
import com.iflytek.mapper.UserMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Windows
 * @description 针对表【user】的数据库操作Service实现
 * @createDate 2022-09-11 16:27:23
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
        implements UserService {

    @Override
    public void saveUser(User user) throws Exception {
        User u = this.getBaseMapper().selectByPhone(user.getPhone());
        if (u == null) {
            this.getBaseMapper().insert(user);
        } else throw new Exception("手机已存在");
    }

    @Override
    public void catchMark(Integer[] ids) {
        this.getBaseMapper().markCatchUser(ids);
    }

    @Override
    public PageInfo<User> findByParams(User params, Integer pageNum, Integer pageSize) {

        PageHelper.startPage(pageNum,pageSize);
        Page<User> page = this.getBaseMapper().selectByParams(params);

        return page.toPageInfo();

    }

    @Override
    public User getUserById(int id) {
        return this.getBaseMapper().selectUserById(id);
    }
}




